###############
# Master code
# US election
###############


# clear memory
rm(list=ls())

# load rstan library
library(rstan)
options(mc.cores = parallel::detectCores())
rstan_options(auto_write = TRUE)




# CBQ estimations
t0 <- Sys.time()
source("replication_AN/cbq_vote_AN_q1_s.R")
t1 <- Sys.time()
source("replication_AN/cbq_vote_AN_q2_s.R")
t2 <- Sys.time()
source("replication_AN/cbq_vote_AN_q3_s.R")
t3 <- Sys.time()
source("replication_AN/cbq_vote_AN_q4_s.R")
t4 <- Sys.time()
source("replication_AN/cbq_vote_AN_q5_s.R")
t5 <- Sys.time()
source("replication_AN/cbq_vote_AN_q6_s.R")
t6 <- Sys.time()
source("replication_AN/cbq_vote_AN_q7_s.R")
t7 <- Sys.time()
source("replication_AN/cbq_vote_AN_q8_s.R")
t8 <- Sys.time()
source("replication_AN/cbq_vote_AN_q9_s.R")
t9 <- Sys.time()

# substantive interpretation
source("replication_AN/replicate_AN.R")
source("replication_AN/substantive_interpretation_AN.R")
t10 <- Sys.time()


dur1 = t1 - t0
dur2 = t2 - t1
dur3 = t3 - t2
dur4 = t4 - t3
dur5 = t5 - t4
dur6 = t6 - t5
dur7 = t7 - t6
dur8 = t8 - t7
dur9 = t9 - t8
dur10 = t10 - t9
dur11 = t10 - t0


dur1
dur2
dur3
dur4
dur5
dur6
dur7
dur8
dur9
dur10
dur11


############################################################################################
# To reproduce the original figures and tables, please uncomment the following line
# source("replication_AN/archive/origin_vote.R")

